﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Groupbox;
using System.Collections.Generic;
using System.Xml.Linq;

namespace OntologyWPFSilverlight.Widget
{
    public class GroupCheckBox : Canvas
    {
        
        GroupBox groupBox = null;
        WrapPanel wrapPanel = null;

        public GroupCheckBox()
        {
            Build();
        }

        private void Build()
        {
            groupBox = new GroupBox();
            wrapPanel = new WrapPanel();
            wrapPanel.Orientation = Orientation.Horizontal;
            wrapPanel.HorizontalAlignment = HorizontalAlignment.Left;
            wrapPanel.VerticalAlignment = VerticalAlignment.Top;
            groupBox.Content = wrapPanel;
        }

        public void AddItem(IEnumerable<XElement> nodes) 
        {
            foreach (XElement node in nodes)
            {
                CheckBox checkBoxTemp = new CheckBox();
                checkBoxTemp.Content =  node.Attribute("Name").Value;
                
                //todo:
                //checkBoxTemp.Tag= 
                wrapPanel.Children.Add(checkBoxTemp);
            }
        }

        public void AddLabel(string text) 
        {
            groupBox.Header = text;
        }
    }
}
